<?php
  include_once("sql_connect.php");
  include_once("msg_redirect.php");
?>
<?php 
if($_POST[login] == "yes"){                                   /*查询数据库，邮箱与密码是否能匹配*/
	$u_email = $_POST[email];
	$u_passwd = md5($_POST[password]);
	$my_sql = mysql_query("select * from user_info 
	where u_email = '$u_email' and u_passwd = '$u_passwd'", $connection);
	if (mysql_num_rows($my_sql) == 1){
		$my_result = mysql_fetch_array($my_sql);
		if ($_POST[remember] == "remember"){
			$keep_time = time() + 3600*24*7;
		}
		else $keep_time = time() + 3600*24;
		setcookie("TTU","logined",$keep_time);   
		setcookie("u_no",$my_result[u_no],$keep_time);		//如果成功，则设置cookie并且登陆
		setcookie("u_email",$u_email,$keep_time);
		setcookie("u_name",$my_result[u_name],$keep_time);
		msg_redirect("欢迎登陆深大微博", "home.php");
	}
	else msg_redirect("你的用户名或者密码错误", "index.php");  	/*不成功则返回到首页*/
}
mysql_close($connection);
?>